package com.yloveg.impl;

import java.util.Date;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.yloveg.common.AccessTokenUtil;
import com.yloveg.common.DateUtil;
import com.yloveg.dao.VTokenMapper;
import com.yloveg.dao.VVisitLogMapper;
import com.yloveg.entity.VComplain;
import com.yloveg.entity.VToken;
import com.yloveg.entity.VVisitLog;
import com.yloveg.entity.VVisitor;
import com.yloveg.service.VTokenService;
import com.yloveg.service.VVisitorLogService;

@Service
public class VVisitorLogServiceImpl implements VVisitorLogService {

	@Autowired
    private VVisitLogMapper vVisitorLog;

	@Override
	public int insertVVisitorLog(VVisitLog record) {
		record.setSts("Y");
		record.setCreateTime(new Date());
		return vVisitorLog.insert(record);
	}

	@Override
	public VVisitLog selectByPrimaryKey(Integer id) {
		return vVisitorLog.selectByPrimaryKey(id);
	}

	@Override
	public List<VVisitLog> selectByOpenidAndActidAndTime(VVisitLog record) {
		
		return vVisitorLog.selectByOpenidAndActidAndTime(record);
	}

	@Override
	public int selectByTodayCount() {
		
		return vVisitorLog.selectByToday().size();
	}

	@Override
	public PageInfo<VVisitor> queryVisitorPage(int page, int limit) {
		PageHelper.startPage(page, limit);
		List<VVisitor> vVisitorList = vVisitorLog.queryVisitor();
		PageInfo<VVisitor> resultPage=new PageInfo<VVisitor>(vVisitorList);
		return resultPage;
	}

	@Override
	public List<VVisitLog> selectByActivityid(Integer activityid) {
		
		return vVisitorLog.selectByActivityid(activityid);
	}
	

}
